define(function(require, exports, module) {

    "use strict";
    require("mui");
	require("jquery");
    require("common");
    var muiTips = require("muiTips");
	var abpdata = require("abpinit");
	var abp = abpdata.abpstart;
	require('http://g.alicdn.com/ilw/ding/0.8.9/scripts/dingtalk.js');
	//钉钉返回清除缓存
	var dingTalkNav = require('dd_config');
	//钉钉右边按钮操作
	dingTalkNav.RightNavBar(false, "新增", "default");
	mui.init({
		swipeBack: true, //启用右滑关闭功能
	});
	$(function(){
		//ios
		dingTalkNav.LeftNavBar();
		//ad
		dingTalkNav.leftAndroid();
//		//客服电话
//		mui("body").on('tap',"#tel",function() {
//			if(mui.os.plus){
//				plus.device.dial("4000002900");
//			}else{
//				location.href = 'tel:4000002900';
//			}
//		});	
		mui("body").on('tap', ".putIn button", function() {
			var content = $("#feedback").val();
			var userEmail = $("#userEmail").val();
			var userTel = $("#userTel").val();
			var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
//			var content = $("#feedback").val();
			if(!content){
				muiTips.alertAutoma(' ', "请输入您对我们的建议，我们将会不断地改进!", 2, "default");
				return;
			}
			if(!userEmail && !userTel){
				muiTips.alertAutoma(' ', "两种联系方式填写任意一项即可！", 2, "default");
				return;
			}
			if(userEmail && !filter.test(userEmail)){
				muiTips.alertAutoma(' ', "您输入的邮箱不正确！", 2, "default");
				return;
			}
			if(userTel && !(/^1[34578]\d{9}$/.test(userTel))){
				muiTips.alertAutoma(' ', "您输入的手机号不正确！", 2, "default");
				return;
			}
			var option = {};
			var dataModel = {
			  "userMobile": "userTel",
			  "userEmail": "userEmail",
			  "fullName": "",
			  "content": "content"
			};
			abp.services.app.feedBack.feedBack(dataModel, option).
			done(function(data) {
				muiTips.alertAutoma(' ', "非常感谢您的建议,24小时内专线客服会与您联系！", 1, pageOpen);
			}).fail(function(data) {
				muiTips.alertAutoma(' ',data.message, 2, "default");
			});

		});
		
		function pageOpen(){
			document.location.href="../../src/feedbackHelp/help.html?dd_nav_bgcolor=FFFF943E";
		}
	});

});
